// import axios from '@/utils/request'
// const STATUS = {
//   '-1': '已退款',
//   1: '已支付'
// }
export default {
  OfficerInvoice: {
    entity: { name: 'Invoice', prefix: `officer` },
    form: {
      fields: [
        'status',
        'paidTime'
      ]
    },
    list: {
      export: {
        query: {
          '@display': `{
                'id' : 'entity.getId()',
                'transactionId' : 'entity.getTransactionId()',
                'outTradeNo' : 'entity.getOutTradeNo()',
                'status' : '{0: "等待支付",1: "已支付",2: "已完成","-1": "已退款","-2": "已取消或支付失败"}[entity.getStatus()]',
                'amount' : 'entity.getAmount()',
                'refunds' : 'entity.getRefunds()',
                'paidTime' : 'entity.getPaidTime().format("Y-m-d H:i:s")',
                'createdTime' : 'entity.getCreatedTime().format("Y-m-d H:i:s")'
            }`,
          'limit': 100000000
        },
        label: {
          'id': 'id',
          'transactionId': '交易号',
          'outTradeNo': '订单编号',
          'status': '状态',
          'amount': '金额',
          'refunds': '退款金额',
          'paidTime': '支付时间',
          'createdTime': '创建时间'
        }
      },
      disabled_actions: ['new', 'lines'],
      query: {
        '@filter': 'entity.getStatus() == "1" && entity.getGateway() == "commonQuery"',
        '@order': 'entity.id|DESC'
      },
      list_filter: {
        'transactionId': '交易号',
        'outTradeNo': '订单编号',
        beforePaidTime: {
          expression: 'entity.getPaidTime() >= datetime.get(":value  08:00:00")',
          label: '支付开始时间',
          type: 'date'
        },
        afterPaidTime: {
          expression: 'entity.getPaidTime() <= datetime.get(":value 07:59:59")',
          label: '支付结束时间',
          type: 'date'
        },
        beforeCreatedTime: {
          expression: 'entity.getCreatedTime() >= datetime.get(":value 08:00:00")',
          label: '创建开始时间',
          type: 'date'
        },
        afterCreatedTime: {
          expression: 'entity.getCreatedTime() <= datetime.get(":value 07:59:59")',
          label: '创建结束时间',
          type: 'date'
        }
        // status: Object.assign({ __label: '状态' }, STATUS),
      },
      list_display: [
        'id',
        { property: 'transactionId', label: '交易号' },
        { property: 'outTradeNo', label: '订单编号' },
        {
          property: 'status', label: '状态',
          component: {
            methods: {
              filter: (type, status) => [
                { value: -2, label: '已取消或支付失败', tagType: 'danger' },
                { value: -1, label: '已退款', tagType: 'danger' },
                { value: 0, label: '等待支付', tagType: 'warning' },
                { value: 1, label: '已支付', tagType: 'success' },
                { value: 2, label: '已完成', tagType: '' }
              ].find(obj => obj.value === status)[type]
            },
            props: ['data'],
            render(h) {
              return (
                <el-tag type={this.filter('tagType', this.data)}>
                  {this.filter('label', this.data)}
                </el-tag>
              )
            }
          }
        },
        {
          property: 'amount', label: '金额',
          component: {
            props: ['data'],
            render(h) {
              return <p>￥{this.data}</p>
            }
          }
        },
        {
          property: 'refunds', label: '退款金额',
          component: {
            props: ['data'],
            render(h) {
              return <p>￥{this.data}</p>
            }
          }
        },
        'paidTime',
        'createdTime'
      ]
    }
  }
}
